#include <iostream>
using namespace std;

#include "summera.h"
#include "hr_time.h"
#include "data_v.h"
#include "map_ip.h"
#include "ip_freq.h"

namespace uppg31
{
	void maina()
	{
		summera s;
		cout << s.sum_rekursiv(3, 10) << endl;
	}

	void mainb()
	{
		summera s;
		cout << s.sum_iterativ(3, 10) << endl;
	}

	void mainc()
	{
		summera s;
		CStopWatch w;
		double timeInEmptyLoop;
		double timeRekursiv;
		double timeIterativ;
		int numLoops = 100;
		volatile int n;

		w.startTimer();
		for (int i = 0; i < numLoops; i++)
		{
			n = 1;
		}
		w.stopTimer();
		timeInEmptyLoop = w.getElapsedTime();

		w.startTimer();
		for (int i = 0; i < numLoops; i++)
		{
			n = s.sum_rekursiv(3, 1000);
		}
		w.stopTimer();
		timeRekursiv = (w.getElapsedTime() - timeInEmptyLoop) / numLoops;

		w.startTimer();
		for (int i = 0; i < numLoops; i++)
		{
			n = s.sum_iterativ(3, 1000);
		}
		w.stopTimer();
		timeIterativ = (w.getElapsedTime() - timeInEmptyLoop) / numLoops;

		cout << "Tid rekursiv : " << timeRekursiv * 1000 << " ms." << endl;
		cout << "Tid iterativ : " << timeIterativ * 1000 << " ms." << endl;
	}
}

namespace uppg32
{
	void main()
	{
		//data_v dv("192.168.0.1");
		map_ip mi("ip_one.txt");
		string ip = "180.116.169.151";
		cout << "Antal uppkopplingar " << ip << " : " << mi.getNumConnections(ip) << endl;
	}
}

namespace uppg33
{
	void main()
	{
		uppg32::map_ip mi("ip_one.txt");
		ip_freq ipf(mi);
		ipf.displayTop10();
	}	
}

int main()
{
	//uppg31::maina();
	//uppg31::mainb();
	uppg31::mainc();
	//uppg32::main();
	//uppg33::main();
	system("pause");
	return 0;
}